Skip to content

feat(lk): read evals and eval results under --user-auth - #1152

Merged
jmcclanahan merged 14 commits into
mainfrom
jakemcclanahan/eval-reads
Dec 2, 2026
Merged

jmcclanahan merged 14 commits into
mainfrom
jakemcclanahan/eval-reads

Conversation

@jmcclanahan

@jmcclanahan jmcclanahan commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

What

Lets a person or coding agent signed in with --user-auth read a project's evals and their results from lk. An eval is a set of criteria that LiveKit checks on each finished live session; a session label is the intent or outcome an LLM assigns to each session.

  • lk agent eval list | get EVAL_ID [--revision N | --draft] | history | diff --from V --to V | defaults
  • lk agent eval label list [--kind intent|outcome] | settings
  • lk analytics evals: pass/fail/undecided counts per eval, version, criterion, agent and error code (GetEvalResults, READ)
  • lk analytics labels: sessions per intent/outcome, intent → outcome pairs, failed share per label (GetSessionLabelResults, READ)
  • lk analytics eval-sessions (--eval-id, --verdict, --criterion-id, paged) and lk analytics session evals RM_ID: per-session verdicts, criteria, judge answers and failure reasons (ADMIN)

Why

The Public API serves evals in production (livekit/public-api-server#211, livekit/public-api-server#212, livekit/public-api-server#213, livekit/public-api-server#216, livekit/public-api-server#219), and the MCP has them as tools, but lk had no commands for them.

How

  • Same shape as feat(lk): lk analytics logs, log-patterns and insights under --user-auth #1146: results reads live under lk analytics and reuse projectRead, timeRangeFlags, readPages and the empty-read / 403 messages. Session and eval commands share one actionWithID. Definitions and labels live under lk agent eval, beside lk agent simulate. It is hidden until a user signs in, like the other Public-API-only groups.
  • Definitions are kept verbatim: get and defaults decode the definition as raw JSON. The generated type drops unknown properties and stores pass_threshold as a float32, so get --json would otherwise not round-trip. PR 2 relies on this for edits.
  • Label filters: --intent-id / --outcome-id take LBL_…, other, or unlabeled. The API spells unlabeled as an empty string, which is awkward to pass on a command line.
  • Checks before the project lookup: an unknown verdict, kind or sort order and blank IDs fail early. The API enforces which filters combine, such as --criterion-id needing --eval-id.
  • Names over IDs: eval-sessions shows intents, outcomes and evals by name, with one extra read each, since its response carries only the IDs.

Writes (create/validate/publish/rollback/delete, label CRUD, settings) follow in a stacked PR.

Testing

  • go build ./..., go vet ./..., go test ./... and go test -race ./cmd/lk ./pkg/public/... pass. The race run needed a test fix: six agent_dev_test.go tests left devSession.run printing through the shared out after they returned, and the new agent_eval_test.go sorts right after them. They now wait for it to stop.
  • New unit tests cover each read's query params, the refusals sent before any request, table and --json output, empty reads, and 403/404 messages.
  • New testscript eval-reads-with-user-auth.txtar runs the built binary against the fake Public API. Each canned body decodes strictly into the generated type, and each query is matched exactly.
  • golangci-lint is clean (run in review).
  • Ran against staging on the evals seed project: list, get, diff, eval-sessions and session evals.

🤖 Generated with Claude Code

Topherhindman and others added 8 commits November 24, 2026 14:00
Picks up the Public API's project-level observability reads:
ListProjectLogs, ListLogPatterns and GetAgentInsights. Nothing calls
them yet.

Also picks up what the spec gained since the last regeneration: the
eval and session label RPCs, GetSessionEvals, ListEvalSessions,
GetEvalResults, GetSessionLabelResults, and Agent Builder, whose
service is now AgentBuilderService in place of BuilderAgentService.
Nothing in lk calls them.

Generated from livekit/public-api-server@16e4400
Reads the Public API's ListProjectLogs: the log records that the logs
page on the dashboard lists, from the project's agents, client SDKs and
LiveKit, newest first, one line per record with its time, level,
source, session, logger and message. --json prints the records as the
API sends them.

--since, or --start and --end (a UTC date or an RFC 3339 time), set the
range; without them the server reads the last 24 hours. --log-level,
--source, --session-id and --query filter, --sort-order orders, and
--limit and the hidden --cursor page, as for lk analytics session logs.

The read is for project admins. A refusal says so, a query the server
can't parse gets a hint about the search syntax (an attribute needs its
@), and with user data recording off the error names the settings page,
as the session reads do.
Reads the Public API's ListLogPatterns: the patterns that the logs page
on the dashboard groups a project's log records into, ranked, one row
each with its number of records, level, source, first and last record,
and template. A note on stderr says how many records the range holds
and, on a project with many records, that the counts are estimates.
--json prints the API's response, with each pattern's counts over time
and its variants.

It takes the same range flags as lk analytics logs, plus --min-level
(the server's default is WARN), --source agent|client, --agent-name,
--agent-id, --session-id, --query, --rank events|first-seen|last-seen
and --limit. The list is one page, so there is no --cursor.

The read is for project admins, and its errors say so as the logs'
do.
Reads the Public API's GetAgentInsights: the data that the agent
dashboards of LiveKit Cloud show, as four tables. The totals; the
latencies that have measurements (end-to-end, LLM and realtime time to
first token, TTS time to first byte, transcription and end-of-utterance
delay, tool calls) with p50, p95, p99, mean and max; one row for each
agent and deployment, busiest first; and one row for each model, with
its tokens, characters or seconds of audio. --json prints the API's
response.

It takes the same range flags as lk analytics logs, reading the last 7
days by default, and --agent-id and --agent-name, repeatable, to select
agents. Every project member can read it, so a refusal says the caller
has no access to the project rather than that it needs an admin.
- A project read's refusal now goes through readAPIError, which
  sessionAPIError also calls, so the two no longer repeat the same
  permission-denied wording.
- The help says that a lone --end moves the range too: each read covers
  its default length before --end. It also says that times print in
  local time.
- The hint for a query the server can't parse no longer says that a
  missing @ is the only cause.
- logs' usage line lists --sort-order and --limit, and --source's help
  gives a participant joining as its platform example, the proto's
  own example.
- log-patterns prints "1 pattern shown", not "1 patterns".
- insights prints a dash for an STT's requests, which the API always
  counts as 0.
Adds client calls for the Public API's eval reads: ListEvals, GetEval,
ListEvalHistory, DiffEvalRevisions, GetEvalDefaults, ListSessionLabels,
GetSessionLabelSettings, GetEvalResults, GetSessionLabelResults,
ListEvalSessions and GetSessionEvals, with their renderers.

GetEval and GetEvalDefaults keep the definition as the API sent it: the
generated type drops unknown properties and stores pass_threshold as a
float32.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lk agent eval list|get|history|diff|defaults and lk agent eval label
list|settings read a project's evals and session labels. lk analytics
evals|eval-sessions|labels and lk analytics session evals read their
results.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Six agent dev tests left devSession.run running after they returned. It
prints through the shared out, so it raced with the next test that
replaced out; the new agent_eval_test.go sorts right after them and
tripped -race.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

jmcclanahan and others added 4 commits December 1, 2026 14:34
Print the reason on its own lines wrapped at 80 columns and the transcript
excerpt quoted with "> " as written, not Go-quoted. Leave "on -" out of an
eval heading when the session has no agent name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The eval sessions response carries only the label IDs, so read the project's
labels (deleted ones included) once and show each label by name. A failed
label read falls back to the IDs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lk analytics eval-sessions reads the project's evals once and shows each eval
by name, cut to 30 characters, falling back to the ID. lk analytics session
evals prints a blank line between one eval's failures and the next eval.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A flag given with a blank ID used to read every session, as if it were left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from topherhindman/observability-commands to main December 1, 2026 21:56

@Topherhindman Topherhindman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took a pass at cbfb3f5, looks good and follows the analytics patterns. couple of nits inline. on the body: the bare #212/#213/#216/#219 link to livekit-cli PRs here, they want livekit/public-api-server#N, and "merge #1146 first" is stale now that it's in (rebase onto main is one small conflict in the script_test route table). golangci-lint is clean too fwiw

Comment thread cmd/lk/agent_eval.go Outdated
// Like projectRead's, the action refuses to run without --user-auth before
// checking anything else, then reads the EVAL_ID argument and the command's
// options, so a bad flag fails before the project lookup.
func evalRead[O any](

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is sessionRead with "eval ID" in the error. could sessionRead take the id name (the actionWithID shape from #1153) so there's just one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in ee4ff4f: one actionWithID(idName, …); sessionRead and evalAction wrap it.

Comment thread cmd/lk/analytics_evals.go Outdated
Name: "eval-sessions",
Usage: "List the sessions that a project's evals scored, with their verdicts (requires --user-auth)",
UsageText: "lk analytics eval-sessions [--since DURATION | --start TIME [--end TIME]] [--eval-id EVAL_ID " +
"[--verdict VERDICT | --criterion-id ID]] [--agent-name NAME ...] [--intent-id ID ...] [--outcome-id ID ...] " +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this nests --verdict under --eval-id, but --verdict works on its own (the description says so too). only --criterion-id needs --eval-id

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ee4ff4f.

Comment thread cmd/lk/analytics_evals.go Outdated
Usage: "Print only the sessions in which the eval in --eval-id failed the criterion `ID`; can't be used with --verdict",
},
&cli.StringSliceFlag{
Name: "agent-name",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: agent-name / intent-id / outcome-id here are the same three flags as evalFilterFlags. one helper for both?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in ee4ff4f: both use sessionFilterFlags().

Comment thread pkg/public/eval_results.go Outdated
criterionID := strings.TrimSpace(opts.CriterionID)
if criterionID != "" {
if evalID == "" {
return nil, fmt.Errorf("a criterion needs the eval it belongs to")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the server already refuses a criterionId without an evalId or with a verdict. do we need our own copy of that rule? the enum parsing makes sense here, this feels like it'll drift

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, dropped in ee4ff4f. Enum parsing stays.

jmcclanahan and others added 2 commits December 1, 2026 17:03
…eads

# Conflicts:
#	cmd/lk/analytics.go
#	cmd/lk/analytics_project.go
#	cmd/lk/analytics_project_test.go
#	cmd/lk/script_test.go
#	pkg/public/project_logs.go
#	pkg/public/project_logs_test.go
- sessionRead and evalAction share one actionWithID, which takes the ID's name.
- eval-sessions and the eval results reads share the agent, intent and outcome
  filter flags.
- Drop the client's copy of the criterion rules; the API refuses a criterion
  without its eval or with a verdict.
- The eval-sessions usage shows --verdict works without --eval-id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jmcclanahan
jmcclanahan merged commit 73d520a into main Dec 2, 2026
27 checks passed
@jmcclanahan
jmcclanahan deleted the jakemcclanahan/eval-reads branch December 2, 2026 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants